'''多态不同的对象调用相同的方法得到不同的结果'''
class H2O:
    def __init__(self,name,tempreature):
        self.name = name
        self.tempreature = tempreature
    def turn_water(self):
        if self.tempreature<0:
            print("[%s]:温度太低冻结成冰了" % self.name)
        elif self.tempreature>100:
            print("[%s]:温度过高升华成水蒸气了" % self.name)
        elif 0 < self.tempreature < 100:
            print("[%s]:液化成水了" % self.name)
class Water(H2O):
    pass
class Ice(H2O):
    pass
class Stream(H2O):
    pass
'''多态、不同的对象调用相同的方法得到不同的结果'''
w1=Water("水",56)
i1=Ice("冰",-77)
s1=Stream('蒸汽',400)
def fun(obj):
    return obj.turn_water()

fun(w1)
fun(i1)
fun(s1)